//
//  ImageVCell.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/16.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "ImageVCell.h"


@implementation ImageVCell
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor =backColor;
    }
    return self;
}
-(void)loadCell:(UIImage *)image isShow:(BOOL)Show
{
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    if (Show) {//展示照片
        
        self.imageV = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:self.imageV];
        self.imageV.hidden = NO;
        self.imageV.image = image;
        [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        _imageV.clipsToBounds = YES;
        _imageV.contentMode = UIViewContentModeScaleAspectFill;
        
        UIButton *btn = [TomamaUI createButton:0 Frame:CGRectMake((SCREENW-40*screenW_6)/3 - 42*screenW_6, 0, 42*screenW_6, 42*screenW_6) targ:self sel:@selector(deletePhoto) titleColor:nil font:nil title:nil image:@"Order_cancel" backGroundImage:nil];
        [self.contentView addSubview:btn];
        
//        self.deleteImageV = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.contentView.frame)-30*screenW_6, 5*screenW_6, 20*screenW_6, 20*screenW_6)];
//        self.deleteImageV.image = [UIImage imageNamed:@"Order_cancel"];
//        self.deleteImageV.userInteractionEnabled = YES;
//        [self.contentView addSubview:self.deleteImageV];
        
    }else//展示添加图片
    {
        self.imageV.hidden = YES;
        self.deleteImageV.hidden = YES;
        UIImageView *photoImageV = [[UIImageView alloc]init];
        photoImageV.image = [UIImage imageNamed:@"Foeumcamera"];
        photoImageV.center = CGPointMake(self.frame.size.width/2, self.frame.size.height/2-10*screenW_6);
        photoImageV.bounds = CGRectMake(0, 0, photoImageV.image.size.width, photoImageV.image.size.height);
        photoImageV.userInteractionEnabled = YES;
        [self.contentView addSubview:photoImageV];
        
        UILabel *lab = [TomamaUI createLabel:CGRectMake(0, CGRectGetMaxY(photoImageV.frame), self.frame.size.width, 30*screenW_6) textAligment:1 font:[UIFont systemFontOfSize:14*screenW_6] textColor:TextGray text:@"照片"];
        lab.userInteractionEnabled = YES;
        [self.contentView addSubview:lab];
    }
}

-(void)deletePhoto
{
    if (_block) {
        _block();
    }
}


@end
